import Vue from 'vue'
import App from './App'
import {updateurl, amap_key} from './common/service.js';
import amap from './common/amap-wx.js';

//全局注入w-loading组件
import wLoading from "@/components/loading/w-loading.vue";
Vue.component('w-loading',wLoading)

Vue.config.productionTip = false

App.mpType = 'app'

const app = new Vue({
    ...App
})
app.$mount();

Vue.prototype.$updateurl = updateurl;
Vue.prototype.$fm = {
	innerAudioContext: null,
	channel:{},
	songs:[],
	playing:{
		title:'--',
		artist:'--',
		channelName:'--',
		cover:'http://img1.doubanio.com/img/fmadmin/medium/2882930.jpg',
		like: false
	},
	playState:{
		isPlaying:false,
		leftRotate:225,
		rightRotate:225
	}
}

Vue.prototype.$amapPlugin = new amap.AMapWX({key: amap_key});

Array.prototype.indexOf = function (val) {
    for (var i = 0; i < this.length; i++) {
        if (this[i] == val) return i;
    }
    return -1;
};

Array.prototype.indexOfById = function (val) {
    for (var i = 0; i < this.length; i++) {
        if (this[i] && (this[i]['id'] == val)) return i;
    }
    return -1;
};

Array.prototype.indexOfByFieldAndId = function (field, val) {
    for (var i = 0; i < this.length; i++) {
        if (this[i] && (this[i][field] == val)) return i;
    }
    return -1;
};

Array.prototype.remove = function (val) {
    var index = this.indexOf(val);
    if (index > -1) {
        this.splice(index, 1);
    }
};

Array.prototype.removeById = function (val) {
    var index = this.indexOfById(val);
    if (index > -1) {
        this.splice(index, 1);
    }
};

Array.prototype.removeByFieldAndId = function (field, val) {
    var index = this.indexOfByFieldAndId(field, val);
    if (index > -1) {
        this.splice(index, 1);
    }
};